import request, { get, post, put, deleteData } from './http';

// import Mocks from '../mock/index.js';
console.log(location.origin);
// const root = location.origin;

// http://localhost:9995/adminTableList?_sort=id&_order=desc
// ============================================================获取
export function loginApi(params) {
  return get('http://localhost:9995/tokenLogin', params);
}

export function userinfoApi(params) {
  return request({
    url: 'http://localhost:9995/userinfo',
    method: 'get'
  });
}

export function adminList(params) {
  return get('http://localhost:9995/adminTableList', params);
}

export function routerList(params) {
  return get('http://localhost:9995/routerList', params);
}

export function imageList(params) {
  return get('http://localhost:9995/imageList', params);
}

export function statusCodeList(params) {
  return get('http://localhost:9995/statusCodeList', params);
}

export function imageTextList(params) {
  return get('http://localhost:9995/imageTextList', params);
}

export function noviceList(params) {
  return get('http://localhost:9995/noviceList', params);
}

// ================================================================用户管理接口
export function userList(params) {
  return get('http://localhost:9995/userList', params);
}

export function addUser(data) {
  return post('http://localhost:9995/userList', data);
}

export function updataUser(data) {
  return put('http://localhost:9995/userList/'+ data.id, data);
}

export function deleteUser(id) {
  return deleteData('http://localhost:9995/userList/'+ id);
}

// ================================================================公告管理接口
export function noticeManage(params) {
  return get('http://localhost:9995/noticeManage', params);
}

export function addNotice(data) {
  return post('http://localhost:9995/noticeManage', data);
}

export function updataNotice(data) {
  return put('http://localhost:9995/noticeManage/'+ data.id, data);
}

export function deleteNotice(id) {
  return deleteData('http://localhost:9995/noticeManage/'+ id);
}

// ================================================================消息管理接口
export function messageManage(params) {
  return get('http://localhost:9995/messageList', params);
}

export function addMessage(data) {
  return post('http://localhost:9995/messageList', data);
}

export function updataMessage(data) {
  return put('http://localhost:9995/messageList/'+ data.id, data);
}

export function deleteMessage(id) {
  return deleteData('http://localhost:9995/messageList/'+ id);
}
